For our analysis, in addition to the state-wise data package, we will use the following packages for data wrangling and visualization.
library(devtools)
library(tidyverse)
library(sf)
library(tidycensus)
library(tmap)
library(censusr)
library(here)
library(janitor)
library(lubridate)
The data comes from a data set posted by Open Data DC from their own website that consists of all the crime data for past years. The data can be downloaded in .csv, .geojson and various other formats. The data is available at (“https://opendata.dc.gov/datasets/crime-incidents-in-2021/explore”) and is updated daily.
The datasets for census data and the crime data were joined together using
df = st_join(crime, neigh)
The tmap code below has been set to view mode. Each neighborhood has been represented by a a different shade and been filled with the area. The black dots represents any crime that has happened in that particular area.
tmap_mode("view")
tmap mode set to interactive viewing
tm_shape(neigh) +
tm_polygons("shapearea") +
tm_shape(crime) +
tm_dots(col="offense", palette = "Set1", stretch.palette = FALSE, size = 0.02, shape = 2) +
tm_layout(legend.outside = TRUE)
Symbol shapes other than circles or icons are not supported in view mode.